#include "key.h"
#include "oled.h"
#include "stm32f10x.h"

#define OLED 0
#define KEY 1

#define TEST_OBJ OLED

void delay(unsigned int n)
{
    int i;
    for (i = 0; i < n; i++) { };
}

// 全是你的名字
// 使用前要使用OLED_Init()初始化OLED
void AllYourName(void)
{
    unsigned int i;
    for (i = 0; i < 8; i++) {
        OLED_P16x16Ch(i * 16, 0, 32);
        OLED_P16x16Ch(i * 16, 2, 33);
        OLED_P16x16Ch(i * 16, 4, 34);
    }
    OLED_P16x16Ch(0, 6, 32);
    OLED_P16x16Ch(1 * 16, 6, 33);
    OLED_P16x16Ch(2 * 16, 6, 34);

    OLED_P16x16Ch(3 * 16, 6, 32);
    OLED_P16x16Ch(4 * 16, 6, 33);
    OLED_P16x16Ch(5 * 16, 6, 34);

    OLED_P16x16Ch(6 * 16, 6, 35);
    OLED_P16x16Ch(7 * 16, 6, 36);
}

void main(void)
{

#if TEST_OBJ == OLED
    OLED_Init();
    OLED_Clear();
    AllYourName();

#elif TEST_OBJ == KEY
    OLED_Init();
    OLED_Clear();
    Key_Init();
    unsigned int KeyCode = KEY_NONE;
    while (1) {

        while (KeyCode == KEY_NONE) {
            KeyCode = GetKey();
        }
        OLED_Clear();
        OLED_ShowChar(0, 0, '0' + KeyCode);
        KeyCode = KEY_NONE;
    }

#endif

    while (1) { };
}